# Maintainer: Anatol Pomozov

pkgname=s2n-tls
pkgver=1.3.43
pkgrel=1
pkgdesc='A C99 implementation of the TLS/SSL protocols that is designed to be simple, small, fast, and with security as a priority'
arch=(loong64 x86_64)
url='https://github.com/aws/s2n-tls'
license=(Apache)
provides=(s2n) # upstream renamed the project from s2n to s2n-tls
conflicts=(s2n)
replaces=(s2n)
depends=(openssl gcc-libs)
makedepends=(cmake)
source=(s2n-tls-$pkgver.zip::https://github.com/aws/s2n-tls/archive/v$pkgver.zip)
sha256sums=('a3ec8b4d30408bc22f7e88673be1d53f5fc4b0ae50ee9b120580315931283813')

build() {
  cd s2n-tls-$pkgver

  cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=ON -DUNSAFE_TREAT_WARNINGS_AS_ERRORS=OFF \
      -S . -B build
  cmake --build build
}

check() {
  cd s2n-tls-$pkgver
  cmake --build build --target test
}

package() {
  cd s2n-tls-$pkgver

  cmake --build build --target install -- DESTDIR="$pkgdir/"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
